package drds.global_transaction.api.rpc.rpc_server;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

import io.netty.channel.Channel;

public interface Sender
{
	/**
	 * Send request to client by the upper level. Actually, just
	 * BranchTransactionCommitRequestMessage
	 * /BranchTransactionRollbackRequestMessage will be sent from
	 * transaction_coordinator to resource_manager_client client. No case for
	 * sending a request to transaction_manager_client client. ResourceId is useless
	 * by case of sending a transaction_manager_client request.
	 */
	void sendRequest(String resourceId, String clientIp, String applicationId, Object request /*
																								 * TODO: this should be Message
																								 */);

	/**
	 * 同步调用client
	 */
	Object sendSynRequest(String resourceId, String clientIp, String applicationId, Object msg, long timeout) throws IOException, TimeoutException;

	/**
	 * 同步调用client
	 */
	Object sendSynRequest(String resourceId, String clientIp, String applicationId, Object msg) throws IOException, TimeoutException;

	//
	void sendResponse(Channel channel, long messageId, Object message);

	/**
	 *
	 */
	void sendResponse(long messageId, String resourceId, String clientIp, String applicationId, Object message);

}
